/**
 * Created by Evan on 2016/7/22.
 */
var gprop = require('../etc/config').prop;
var log = require('./../controllers/log');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
exports.use = function (app, express) {
	log.use(app);
	//设置当前模式为开发模式
	app.set('env', 'development');
	app.engine('ejs', require('ejs').renderFile);
	app.set('views', gprop.server_path + "/views");
	app.set('view engine', 'ejs');
	app.use(express.static(gprop.server_path + "/public"));
	app.use(bodyParser.json({limit: '10mb'}));
	app.use(bodyParser.urlencoded({extended: false, limit: '10mb'}));
	app.use(cookieParser());
	app.use(function (req, res, next) {
		if (req.url.indexOf("/favicon.ico") >= 0) return res.end();
		//var param={query:req.query,body:req.body,file:req.file||{}};
		//logger.debug(param);
		res.setHeader("Access-Control-Allow-Origin", "*");
		//某些浏览器或者某些环境下，浏览器一直认为请求未结束，为避免误会我们直接设置连接关闭
		res.setHeader("Connection", "Close");
		// res.setHeader("X-Frame-Options", "SAMEORIGIN");
		next();
	});
}